package com.ycsj.goldmedalnewconcept.parent.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.parent.bean.RedPackageInfo;

import java.util.List;

/**
 * 我的红包列表适配器
 * Created by Administrator on 2018/6/20 0020.
 */

public class RedPackageRvAdapter extends BaseQuickAdapter<RedPackageInfo.RedPacketBean, BaseViewHolder> {
    private Context context;


    public RedPackageRvAdapter(Context context, int layoutResId, @Nullable List<RedPackageInfo.RedPacketBean> data) {
        super(layoutResId, data);
        this.context = context;
    }


    @Override
    protected void convert(BaseViewHolder helper, RedPackageInfo.RedPacketBean item) {
        RelativeLayout rlMoney = helper.getView(R.id.rl_money);

        //红包金额
        TextView tvMoney = helper.getView(R.id.tv_money);
        tvMoney.setText("￥" + item.getMoney());

        //红包标题
        TextView tvName = helper.getView(R.id.tv_name);
        tvName.setText(item.getSchool() + "");

        //红包编号
        TextView tvNum = helper.getView(R.id.tv_no);
        tvNum.setText("红包编号:" + item.getId());

        //领取时间
        TextView tvTime = helper.getView(R.id.tv_time);
        tvTime.setText(item.getExpirationDay() + "到期");

        //领取人手机号
        TextView tvTel = helper.getView(R.id.tv_tel);
        tvTel.setText("领取人手机号:" + item.getCustomer());

        //状态
        ImageView lvFlag = helper.getView(R.id.lv_flag);
        if ("2".equals(item.getStatus())) {
            //表示用过
            lvFlag.setVisibility(View.VISIBLE);
            lvFlag.setImageResource(R.drawable.parent_flag_used);
            rlMoney.setBackgroundResource(R.drawable.parent_red_hasused);
        } else if ("1".equals(item.getStatus())) {
            //表示没用过
            lvFlag.setVisibility(View.GONE);
            rlMoney.setBackgroundResource(R.drawable.parent_red_nouse);
        }else if("3".equals(item.getStatus())){
            //表示已失效
            lvFlag.setVisibility(View.VISIBLE);
            lvFlag.setImageResource(R.drawable.teacher_flag_time_out);
            rlMoney.setBackgroundResource(R.drawable.parent_red_hasused);
        }
    }
}
